import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'
import Index from '../views/Index.vue'

Vue.use(VueRouter)

const routes = [
  {
    // 路径和组件的对应关系,对应关系的命名
    path: '/', //路径
    name: 'Index', // 对应关系的名称
    component: Index // 组件
    },
  {
    path: '/about',
    name: 'About',
   // 路由的懒加载写法:相比较上面的写法 可以让初始化文件变小,提高加载速度
    component: () => import('../views/About.vue')
  },
  {
    path: '/news',
    name: 'News',
    component: () => import('../views/News.vue')
  },
  {
    path: '/news_details/:nid',
    name: 'NewsDetails',
    component: () => import('../views/NewsDetails.vue')
  },
  {
    path: '/contact',
    name: 'Contact',
    component: () => import('../views/Contact.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
